package heapsort;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Random;

public class Generator {
	private static int numberThatIsUsed = 100;
	private long[] list;
	public static void main( String[] args ) {
		// the number in the generator is how many numbers will be generated
		@SuppressWarnings("unused")
		Generator gen = new Generator( numberThatIsUsed );
	}
	public Generator( int numbers ) {
		list = new long[numbers];
		for(int i = 0; i < numbers; i++){
			Random rand = new Random();
			int randomInt = rand.nextInt( numbers );
			list[i] = randomInt;
		}
//		writeToFile( ""+numbers );
		writeToFile( numbers, "heapsort100" );
	}
	public void writeToFile( int numbers, String fileName) {
		try{
			FileWriter fsStream = new FileWriter( fileName + ".txt" );
			BufferedWriter outB = new BufferedWriter( fsStream );
			
			for(int i=0; i < numbers; i++){
				System.out.println( "writing now: " + list[i] );
				outB.write( list[i] + " " );
			}
			outB.close();
		}catch( Exception e ){
			e.printStackTrace();
			System.err.println( "Error: " + e.getMessage() );
		}
	}
}